package com.wang.designpattern.iterator;

import java.util.Iterator;
import java.util.List;

public class InfoCollegeIterator implements Iterator {
    // 这里我们需要Department是以怎样的方式存放
    List<Department> departmentList;
    // 索引的位置
    int index = -1;

    public InfoCollegeIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    @Override
    public boolean hasNext() {
        if (index >= departmentList.size() - 1) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public Object next() {
        index ++;
        Department department = departmentList.get(index);
        return department;
    }
}
